CREATE TABLE %LOGGING_TABLE_NAME% 
(
  id number NOT NULL,
  table_name varchar2(32) NOT NULL,
  user_name varchar2(32) DEFAULT user NOT NULL,
  operation char(1) NOT NULL,
  changed timestamp DEFAULT sysdate NOT NULL,
  old_values xmltype,
  new_values xmltype,
  CONSTRAINT %LOGGING_TABLE_NAME%_pk PRIMARY KEY (id),
  CONSTRAINT %LOGGING_TABLE_NAME%_chck_new_values CHECK (operation = 'D' AND new_values IS NULL OR (operation = 'I' OR operation = 'U') AND new_values IS NOT NULL),
  CONSTRAINT %LOGGING_TABLE_NAME%_chck_old_values CHECK (operation = 'I' AND old_values IS NULL OR (operation = 'U' OR operation = 'D') AND old_values IS NOT NULL),
  CONSTRAINT %LOGGING_TABLE_NAME%_chck_operation CHECK (operation = 'I' OR operation = 'U' OR operation = 'D')
)